<?php
namespace Admin\Controller;
use Think\Controller;
class ArticleController extends CommenController {
    
    public function index(){
        $Model = new \Think\Model();
        $sql = 'select u.nickname nname,p.name pname,t.id tid,t.name tname,t.content tcontent,t.status tstatus,t.createtime ctime from pro_user as u, pro_pathclass as p ,pro_text as t where u.id=t.bid AND t.tid = p.id';

        $data = $Model->query($sql);
        //dump($data);
        $this->assign('text',$data);



        $this->display();
    }

    public function delete(){
        $id = $_GET['id'];
        //dump($id);
        $m = M('text');

        $data = $m->where("id = $id") ->delete();

        if($data > 0){
            $this->success('文章回收成功');
        } else{
            $this -> error('文章回收失败或该文章已删除',U('index'));
        }

    }


    public function xianshi(){
        $id = $_GET['id'];
        $m = M('text');
        $data = $m -> where("id = $id") ->save(array('status' => '1'));
        if($data > 0){
            $this->success('文章修改成功');
        } else{
            $this -> error('文章修改失败',U('index'));
        }

    }

    public function yincang(){
        $id = $_GET['id'];
        $m = M('text');
        $data = $m -> where("id = $id") ->save(array('status' => '0'));
        if($data > 0){
            $this->success('文章修改成功');
        } else{
            $this -> error('文章修改失败',U('index'));
        }

    }


}
